package leetcode.D900.T876;

import util.ListNode;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: DYZ
 * @Create: 2022-02-18 13:07:52
 */

class Solution {
    public ListNode middleNode(ListNode head) {
        ListNode p = head, q = head;
        while(true) {
            q = q.next;
            if (q == null)
                return p;
            q = q.next;
            if (q == null)
                return p.next;
            p = p.next;
        }
    }
}
